﻿using System;
using System.Windows.Forms;

namespace HuaCheng.UserControls
{
    public partial class ChannelSimple : UserControl
    {
        #region 全局参数
        private int gid;//柜号
        private int mid;//中位机号
        private int chlMapId;//映射id
        private int chlRealId;//实际id
        private string chlTitle;//显示组合通道号
        public delegate void ChlRevert();//委托修改右键菜单Enable属性
        public event ChlRevert ChlRightMouseClick ;//事件
        #endregion
        #region 初始化
        public ChannelSimple()
        {
            InitializeComponent();
        }
        #region 属性 get set方法
        /// <summary>
        /// 柜号
        /// </summary>
        public int GID
        {
            get { return gid; }
            set
            {
                gid = value;
            }
        }
        public int MID
        {
            get { return mid; }
            set
            {
                mid = value;
            }
        }
        /// <summary>
        /// 映射通道号
        /// </summary>
        public int ChlMapId
        {
            get { return chlMapId; }
            set
            {
                chlMapId = value;
            }
        }
        /// <summary>
        /// 实际通道号
        /// </summary>
        public int ChlRealId
        {
            get { return chlRealId; }
            set
            {
                chlRealId = value;
                this.lblRealId.Text = Convert.ToString(value);
            }
        }
        /// <summary>
        ///  组合通道号
        /// </summary>
        public string ChlTitle
        {
            get { return chlTitle; }
            set
            {
                chlTitle = value;
                this.lblChId.Text = value;
            }
        }
        /// <summary>
        /// 设置参数
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="mid"></param>
        public void SetParam(int gid,int mid, int cid,int realid)
        {
            GID = gid;
            MID = mid;
            ChlMapId = cid;
            ChlRealId = realid;
            ChlTitle = mid + "-" + cid;
        }
        #endregion
        //方法
        public void OnChlRevert()
        {
            if (ChlRightMouseClick != null)
            {
                ChlRightMouseClick();
            }
        }

        /// <summary>
        /// 右键控件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChannelSimple_MouseDown(object sender, MouseEventArgs e)
        {
            OnChlRevert();//监听右键事件 把菜单第一项激活
        }
        /// <summary>
        /// 点击子控件时触发父控件点击事件，避免父控件点击事件被覆盖
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ChildControl_MouseClick(object sender, MouseEventArgs e)
        {
            base.OnMouseClick(e);
        }
        /// <summary>
        /// 点击子控件时触发父控件点击事件，避免父控件点击事件被覆盖
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ChildControl_MouseDown(object sender, MouseEventArgs e)
        {
            base.OnMouseDown(e);
        }
        #endregion
    }
}
